<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateCmsNavMenusTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('cms_nav_menus')) {
            Schema::create('cms_nav_menus', function (Blueprint $table) {
                $table->id();
                $table->integer('nav_id')->comment('导航id:cms_navs.id');
                $table->integer('parent_id')->default(0)->comment('父级id');
                $table->string('name')->comment('菜单名称');
                $table->string('icon')->nullable()->comment('菜单图标');
                $table->string('url')->nullable()->comment('菜单url');
                $table->tinyInteger('type')->default(0)->comment('菜单类型:1:外链,2:内链');
                $table->tinyInteger('status')->default(1)->comment('状态:1:正常,2:禁用');
                $table->integer('sort')->default(100)->comment('排序');
                $table->tinyInteger('is_show')->default(1)->comment('是否显示:1:显示,2:不显示');
                $table->string('path')->nullable()->comment('层级关系,例:0-1-2');
                $table->softDeletes();
                $table->timestamps();
            });
            DB::statement("ALTER TABLE `cms_nav_menus` comment 'CMS前台导航菜单表'");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cms_nav_menus');
    }
}
